package it.tcon.xbeedriver;

import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;

public class XBeeNodeParam{
	
	public enum State {
		PARAM_UNSET (0),
		PARAM_SET (1),
		PARAM_ERROR (2);
		
		private static final Map<Integer,State> lookup = new HashMap<Integer,State>();
		
		static {
			for(State s : EnumSet.allOf(State.class)) {
				lookup.put(s.getValue(), s);
			}
		}
		
		public static State get(int value) { 
			return lookup.get(value); 
		}
		
	    private final int value;
	    
	    State(int value) {
	        this.value = value;
	    }

		public int getValue() {
			return value;
		}
	}
	
	//public static final int PARAM_SET = 1;
	//public static final int PARAM_UNSET = 0;
	//public static final int PARAM_ERROR = 2;
	
	private String paramName;
	private State state;
	private int[] data;
	
	public XBeeNodeParam(String paramName){
		this.paramName = paramName;
		this.state = State.PARAM_UNSET;
		this.data = null;
	}
	public XBeeNodeParam(String paramName,State state){
		this.paramName = paramName;
		this.state = state;
		this.data = null;
	}
	public XBeeNodeParam(String paramName,State state,int[] data){
		this.paramName = paramName;
		this.state = state;
		setData(data);
	}
	
	public void setState(State state){
		this.state = state;
	}
	public State getState(){
		return this.state;
	}
	
	public void setData(int[] data){
		this.data = new int[data.length];
		this.data = data;
	}
	public int[] getData(){
		return this.data;
	}
	
	public void setName(String name){
		this.paramName = name;
	}
	public String getName(){
		return this.paramName;
	}
	
}
